home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
util
/
cli
/
CLI_Tools.lha
/
Tackon.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-03
|
3KB
|
147 lines
/******************************************************************************
MODULE
Tackon.c
DESCRIPTION
Get three strings on Commandline
a path, a name and a suffix,
build a filename from these three
strings and write it to StdOut
NOTES
Kickstart 2.0+ required
compiles w/ Dice 2.07R - inline-pragmas required
compiles w/ SAS/C v6.51
BUGS
there is a strange behaviour if compiled w/ DICE;
- I cannot say why, but If You do not specify
each input-slot, You will get a Enforcer-Hits;
for that reason, I'll distribute Chris' SAS-executable
TODO
EXAMPLES
> tackon xx yy zz
xx/yy.zz
> tackon xx :yy -zz
:yy-zz
SEE ALSO
Suffix, PathPart, FilePart
INDEX
HISTORY
01-08-93 b_noll created
AUTHOR
Bernd Noll, Brunnenstrasse 55, D-67661 Kaiserslautern
b_noll@informatik.uni-kl.de
******************************************************************************/
/**************************************
Includes
**************************************/
#ifndef EXEC_LIBRARIES_H
# include <exec/libraries.h>
#endif /* EXEC_LIBRARIES_H */
#ifndef CLIB_EXEC_PROTOS_H
# include <clib/exec_protos.h>
#endif /* CLIB_EXEC_PROTOS_H */
#ifndef DOS_DOS_H
# include <dos/dos.h>
#endif /* DOS_DOS_H */
#ifndef CLIB_DOS_PROTOS_H
# include <clib/dos_protos.h>
#endif /* CLIB_DOS_PROTOS_H */
#include <proto/dos.h>
#include <proto/exec.h>
/**************************************
Global Variables
**************************************/
#define BUF_SIZ 1000
#define isalnum(x) ((((x) <= '9') && ((x >= '0'))) || (((x) <= 'Z') && ((x >= 'A'))) || (((x) <= 'z') && ((x >= 'a'))))
#define BODY(x) do{ x }while(0)
#define findlast(s) BODY(char*td=(s);while(*td) ++td; (s)=td;)
/* #define strcpy(d,s) BODY(char*td=(d);char*ts=(s);while(*td=*ts) {++td; ++ts;}) */
char* mstrcpy(char*, char*);
/**************************************
Implementation
**************************************/
long _main (void)
{
const char* version = "$VER: Tackon 1.0 (1.8.93)";
long retval = 20;
struct Library* SysBase = *((struct Library**)4L);
struct Library* DOSBase;
char* b2;
char* buffer;
if (buffer = AllocMem(BUF_SIZ, 0)) {
if (DOSBase = OpenLibrary (DOSNAME, 37)) {
STRPTR argv[4] = { NULL, NULL, NULL };
APTR args;
retval = 10;
if (args = (void*)ReadArgs("PATH,NAME/A,SUFFIX", (LONG*)argv, NULL)) {
retval = 0;
*buffer = 0;
mstrcpy (buffer, argv[0]);
if (AddPart (buffer, argv[1], BUF_SIZ-1)) {
b2 = buffer;
while (*b2) ++b2;
if (argv[2] && isalnum(*argv[2])) {
*b2 = '.';
++b2;
} /* if */
mstrcpy (b2, argv[2]);
PutStr (buffer);
PutStr ("\n");
} /* addpart */
FreeArgs (args);
} /* if */
CloseLibrary (DOSBase);
} /* if */
FreeMem (buffer, BUF_SIZ);
} /* if */
return (retval);
} /* _main */
char* mstrcpy(char*d, char*s)
{
if (s) {
while (*d=*s) {
++d;
++s;
} /* while */
} /* if */
return (d);
}
/******************************************************************************
***** END Tackon.c
******************************************************************************/